package com.bz.content.feign.fallback;

import com.bz.content.feign.CommonContentFeignClient;
import com.bz.pojo.TbContent;
import com.bz.pojo.TbContentCategory;
import com.bz.utils.PageResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * CommonContent 服务器 - openfeign 降级处理
 * 注意：实现服务降级后，db操作失败，将不会抛出异常，也就是说不会抛出异常，事务就不会生效，这时候可以手动判断抛出异常
 */
@Component
public class CommonContentFeignClientFallbackFactory implements FallbackFactory<CommonContentFeignClient> {

    @Override
    public CommonContentFeignClient create(Throwable throwable) {
        return new CommonContentFeignClient() {
            @Override
            public PageResult selectTbContentAllByCategoryId(Integer page, Integer size, Long categoryId) {
                return null;
            }

            @Override
            public Integer insertTbContent(TbContent tbContent) {
                return null;
            }

            @Override
            public Integer deleteContentByIds(Long id) {
                return null;
            }

            @Override
            public List<TbContentCategory> selectContentCategoryByParentId(Long parentId) {
                return null;
            }

            @Override
            public Integer insertContentCategory(TbContentCategory tbContentCategory) {
                return null;
            }

            @Override
            public Integer deleteContentCategoryById(TbContentCategory tbContentCategory) {
                return null;
            }

            @Override
            public Integer updateContentCategory(TbContentCategory tbContentCategory) {
                return null;
            }
        };
    }
}
